#!/bin/sh

case $LANG in
    es*)
	MSG1="<b>Como buenos amiguitos, envíame ese ficherito.</b>"
	MSG2="Informe a quien le va a enviar el archivo que debe escribir lo siguiente en la barra del navegador:"
	MSG3="Si la otra máquina está en su misma red local deberá pedirle que escriba:"
	;;
    gl*)
	MSG1="<b>Como bos amiguiños, enviame ese ficheiro.</b>"
	MSG2="Informe a quen lle vai a enviar o ficheiro que debe escribir o seguinte na barra do navegador:"
	MSG3="Se a outra máquina está na súa mesma rede local deberá pedirlle que escriba:"
	;;
    *)
	MSG1="<b>As good pals send me that file.</b>"
	MSG2="Tell the one who you are sending the file to write in the browser as follow:"
	MSG3="If the other computer is in the same local net as yours (LAN) you have to ask it to write:"
	;;
esac

PUERTO="8080"

# EN DEBIAN LENNY COMENTAR AS DUAS LIÑAS es*) Y gl*), SÓ USA O VALOR EN INGLÉS 
case $LANG in
#	es*) CORTE="dirección";;
#	gl*) CORTE="enderezo";;
	*) CORTE="addr";;
esac

FIJA=`cat /proc/net/dev | cut -f1 -d: | grep eth`
WIFI1=`cat /proc/net/dev | cut -f1 -d: | grep wlan`
WIFI2=`cat /proc/net/dev | cut -f1 -d: | grep ath`
WIFI3=`cat /proc/net/dev | cut -f1 -d: | grep ra`

AAA=`/sbin/ifconfig $FIJA | grep 'inet ' | awk '{print $2}' | sed "s/$CORTE://"`
BBB=`/sbin/ifconfig $WIFI1 | grep 'inet ' | awk '{print $2}' | sed "s/$CORTE://"`
CCC=`/sbin/ifconfig $WIFI2 | grep 'inet ' | awk '{print $2}' | sed "s/$CORTE://"`
DDD=`/sbin/ifconfig $WIFI3 | grep 'inet ' | awk '{print $2}' | sed "s/$CORTE://"`

if [ $AAA != "" ]; then
	IPLOCAL=$AAA
elif [ $BBB != "" ]; then
	IPLOCAL=$BBB
elif [ $CCC != "" ]; then
	IPLOCAL=$CCC
elif [ $DDD != "" ]; then
	IPLOCAL=$DDD
fi

MYIP=$(wget -q -O - checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')

zenity --info --text="$MSG2\n\n<b>http://$MYIP:$PUERTO</b>\n\n\n$MSG3\n\n<b>http://$IPLOCAL:$PUERTO</b>"

python ./droopy -m "$MSG1" -p /usr/share/pixmaps/minino/minino-250x161.png -d /home/minino/Compartida $PUERTO




